package org.grow.lab1.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

//用途：　示例　测试
//运行Lab1Application 浏览器访问localhost:9090 ,能够出现当前时间。
//该接口中途涉及到的文件　SampleController -> WEB-INF/jsp/sample.jsp
//请学习并仿照完成题目要求
@Controller
public class SampleController {
    @GetMapping("/")
    public ModelAndView mvcTest(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("time",
                LocalDateTime.now()
                        .format(DateTimeFormatter.ofPattern(
                                "yyyy-MM-dd:HH-mm-ss")));
        modelAndView.setViewName("sample");
        return modelAndView;
    }
}
